/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"9DDFBA07-4891-41B8-8898-8B2D4D5E469B"}
 */
var fError = null;

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"14735BBA-3427-49F0-9DCF-547ECF0E9359"}
 */
var fUser = null;

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"14B4374C-9172-46F4-B61B-C859AF2D2E9B"}
 */
var fPass = null;

/**
 *
 * @properties={typeid:24,uuid:"BD25BD12-3053-462E-901C-D2799133C671"}
 * @AllowToRunInFind
 */
function Entrar()
{
	var ok = security.authenticate("hoteleria_auth","autenticar",[globals.gCadenaLogin,fUser,fPass]) 
	if (ok == 1)
	{
		return true
	}
	else
	{
		switch (ok)
		{
			case 2:
			{
				//globals.DIALOGS.showErrorDialog('Error','Usuario incorrecto o permiso denegado','OK')
				fError = i18n.getI18NMessage('hoteleria.login.error.permiso_denegado')
				break;
			}
			case 3:
			{
				//globals.DIALOGS.showErrorDialog('Error','*Contraseña incorrecta','OK')
				fError = i18n.getI18NMessage('hoteleria.login.error.password')
				break;
			}
			case 4:
			{
				//globals.DIALOGS.showErrorDialog('Error','Usuario no existe','OK')
				fError = i18n.getI18NMessage('hoteleria.login.error.user')
				break;
			}
		}
	return false
	}
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"697402F6-79C6-405A-8E29-6626F76A8E2A"}
 */
function onShow(firstShow, event) {
	elements.fUser.requestFocus()
}

/**
 * Handle hide window.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"3AD04E3E-BE8F-46B2-93FD-658D4A05D92D"}
 */
function onHide(event) {
	if (security.getUserName() == null)
		return false
		
	return true
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"F20B70BB-CE23-4B26-866A-2AEE8A6032BD"}
 */
function salir(event) {
	application.exit()
}

/**
 * Handle focus gained event of the element.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"8E0D5936-16F9-4AB4-B493-F3118CF877B2"}
 */
function borrarMensaje(event) {
	fError = null
}
